<?php

/*
	任务列表（工作人员）
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return=array();
if($_RQ['op']=='get'){
	$renwus = array();
	$nowyue = mktime(0,0,0,date('m'),1,date('Y'));
	$daytime = mktime(0,0,0,date('m'),date('d'),date('Y'));
	$tcp['all'] = pdo_count('jy_msgorder_tcp',array('uniacid'=>$_SESSION['uniacid']));
	$tcp['day'] = pdo_count('jy_msgorder_tcp',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime));
	$tcplog['all'] = pdo_count('jy_msgorder_tcp',array('uniacid'=>$_SESSION['uniacid']));
	$tcplog['day'] = pdo_count('jy_msgorder_tcp',array('uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime));
	$feetcp['all'] = pdo_count('jy_msgorder_tcp',array('ispay'=>1,'uniacid'=>$_SESSION['uniacid']));
	$feetcp['day'] = pdo_count('jy_msgorder_tcp',array('ispay'=>1,'uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime));
	$price['all'] = pdo_getsum('jy_msgorder_tcp',array('ispay'=>1,'uniacid'=>$_SESSION['uniacid']),'price');
	$price['day'] = pdo_getsum('jy_msgorder_tcp',array('ispay'=>1,'uniacid'=>$_SESSION['uniacid'],'createtime >'=>$daytime),'price');
	$workers = pdo_getall('jy_msgorder_worker',array('uniacid'=>$_SESSION['uniacid']),array('id','mid','title'));
	$workernum = pdo_count('jy_msgorder_worker',array('uniacid'=>$_SESSION['uniacid']));
	if($workernum){
		$workernum = intval(12 / $workernum);
	}
	foreach($workers as &$row){
		$all = pdo_getall('jy_msgorder_tcp',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$row['id'],'status'=>2),'price');
		$alljf=0;
		foreach($all as &$ajf){
			$alljf +=$ajf['price'];
		}
		$day = pdo_getall('jy_msgorder_tcp',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$row['id'],'status'=>2,'complete_time >'=>$nowyue),'price');
		$dayjf=0;
		foreach($day as &$djf){
			$dayjf +=$djf['price'];
		}
		$row['num'] = 2;
		$row['data'] = array($dayjf,$alljf);
		$allnum = pdo_count('jy_msgorder_tcp',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$row['id']));
		$row['value'] = $allnum;
	}
	$workersjifen = $workers;
	foreach($workersjifen as &$row){
		$jifen = pdo_getall('jy_msgorder_tcp',array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$row['id'],'status'=>2),array('price'));
		$row['value'] = 0;
		foreach($jifen as &$v){
			$row['value'] += $v['price'];
		}
	}
	$return['htmls']=array(
		array('type'=>'data','num'=>12,'one_num'=>3,'title'=>'今日数据/总数据','datas'=>array(
			array('title'=>'询单数','num'=>2,'data'=>array($tcp['day'],$tcp['all'])),
			array('title'=>'付费询单数','yuan'=>1,'num'=>2,'data'=>array($feetcp['day'],$feetcp['all'])),
			array('title'=>'对话数','num'=>2,'data'=>array($tcplog['day'],$tcplog['all'])),
			array('title'=>'询单业绩','num'=>2,'data'=>array($price['day'],$price['all'])),
		)),
		array('type'=>'data','one_num'=>$workernum,'title'=>'当月/总任务积分指标','datas'=>$workers),
		array('type'=>'echarts_pie','one_num'=>2,'num'=>6,'width'=>'50%','ecid'=>'wechat','title'=>'专家完成数量','datas'=>array(
			'time' => date("Y-m-d H:i:s", time()),
			'datas'=>$workers,
		)),
		array('type'=>'echarts_pie','one_num'=>2,'num'=>6,'width'=>'50%','ecid'=>'wxapp','title'=>'专家业绩','datas'=>array(
			'time' => date("Y-m-d H:i:s", time()),
			'datas'=>$workersjifen,
		)),
	);
	exi($return);
}
